#ifndef BASE_CTPROPERTIES_H
#define BASE_CTPROPERTIES_H
#include "ctType.h"
#include <ext/hash_map>
#include <string>

class ctProperties
{
        public:

                const std::string &getProperty(const std::string &key)
                {
                        return properties[key];
                }

                void setProperty(const std::string &key,const std::string &value)
                {
                        properties[key] = value;
                }

                std::string & operator[] (const std::string &key)
                {
                        return properties[key];
                }
                void dump(std::ostream &out)
                {
                        property_hashtype::const_iterator it;
                        for(it = properties.begin(); it != properties.end(); it++)
                                out << it->first << " = " << it->second << std::endl;
                }

                DWORD parseCmdLine(const std::string &cmdLine);
                DWORD parseCmdLine(const char *cmdLine);
        protected:
                struct key_hash
                {
                        size_t operator()(const std::string& str) const
                        {
                                unsigned long __h = 0;
                                for (size_t i = 0 ; i < str.size() ; i ++)
                                        __h = 5*__h + str[i];
                                return size_t(__h);
                        }
                };
                struct key_equal 
                        : public std::binary_function<const std::string,const std::string,bool>
                {
                        bool operator()(const std::string &s1,const std::string &s2) const
                        {
                                return strcasecmp(s1.c_str(),s2.c_str()) == 0;
                        }
                };

                typedef __gnu_cxx::hash_map<std::string, std::string, key_hash, key_equal> property_hashtype;

                property_hashtype properties; 
};
#endif //BASE_CTPROPERTIES_H

